import React, { Component } from 'react';
import { connect } from "react-redux";
import { Table } from 'antd';
import moment from 'moment';
// import Mock from 'mockjs'
class FinancialList extends Component {
    constructor(props) {
        super(props);
        this.state = {
            pageNum: 1,
            pageSize: 7,
            userName: '',
            email: '',
            gender: '',
            phone: '',
            startTime: '',
            endTime: '',
            datas: []
        }

        this.columns = [
            {
                title: '时间',
                dataIndex: 'day',
            },
            {
                title: '充值VIP金额',
                dataIndex: 'vipMoney',
            },
            {
                title: '提现金额',
                dataIndex: 'transferMoney',
            },
            {
                title: '提现抽成',
                dataIndex: 'transferGet',
            },
            {
                title: '结算金额',
                dataIndex: 'totalMoney',
            },
            // {
            //     title: '取消订单扣除',
            //     dataIndex: '66',
            // },
            {
                title: '平台抽成金额',
                dataIndex: 'companyCommission',
            },
            {
                title: '平台盈利',
                dataIndex: 'companyGet',
            },


        ];
    }
    componentDidMount() {
        this.init();
    }

    init = () => {
        const { finance } = this.props
        finance({ page: 1, size: 7})

    }

    handleChangeFinanceList = (current, pageSize) => {
        const { newValues } = this.props

        newValues.page = current
        newValues.size = 7
        this.props.finance({ ...newValues })
    }

    render() {
        const { data, userTotal, userLoading } = this.props;
        const { pageNum, pageSize, datas } = this.state;

        const pagination = {
            current: data.current,//当前页
            total: data.total,//总条数
            pageSize: data.size,//页大小
            onChange: this.handleChangeFinanceList,
            showQuickJumper: true,//快速跳转
            showSizeChanger: false//大于50时显示pageSize切换器
        };
        return (
            <div>
                <Table columns={this.columns} loading={userLoading} dataSource={data.records} rowKey={record => record.id} pagination={pagination} />
            </div>
        );
    }
}


const mapState = state => ({
    ...state.finance
});

const mapDispatch = dispatch => ({
    ...dispatch.finance

})

export default connect(mapState, mapDispatch)(FinancialList);